package com.labirynt.impl;

import java.io.IOException;
import java.util.LinkedList;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;

import com.labirynt.GameObject;
/**
 * Aktualna mapa rozgrywki
 * @author Ryszards
 *
 */
public class Mapa extends GameObject{
	private  PartBmpMap[][] tabPartBmpMap;
	private int sizeX;
	private int sizeY;
	 public PartMap activPartMap;
	public Mapa(String name,LinkedList<PartMap> lPartMap,int iTabPart[][],int x, int y,int sizeX,int sizeY,  Context ctx) {
		super(name, x, y, 0, 0);
		 this.sizeX=sizeX;
		 this.sizeY =sizeY;	 		
		 LoadMap lodLevel = new LoadMap("Start",lPartMap,iTabPart,sizeX,sizeY,ctx);
		 tabPartBmpMap = lodLevel.LoadActivPart();
	}
		
		
		 boolean CzyPrzejscie(int x,int y)
		 {			 
			 return !(tabPartBmpMap[x][y].partMap.iPart>0);
		 }
		
		  public int getPart(int x,int y)
		  {
			 	 
			 return tabPartBmpMap[x][y].partMap.iPart;
		   }
		
		

			@Override
			 public void draw(Canvas canvas)
			{
				for(int x=0;x<sizeX;x++){
					for(int y=0;y<sizeY;y++){
						Rect dest = new Rect(x*16, y*16, x*16+16, y*16+16);
						canvas.drawBitmap(tabPartBmpMap[x][y].bmpPart, null, dest, null);
					}
						
						
				}
				
			}


	

		@Override
		public void Update(long now) {
			// TODO Auto-generated method stub
			
		}










	
		public void LoadAnimation(String animBmp, Context ctx) {
			// TODO Auto-generated method stub
			
		}






		
		  public boolean isCollisionWith(GameObject other)  
		  {
		    return  intersectRect( other);
		  }



		@Override
		public boolean isCollision(int x, int y) {
			 return !(tabPartBmpMap[x][y].partMap.iPart>0);
		
		}


		@Override
		public void SetPos(int x, int y) {
			// TODO Auto-generated method stub
			
		}




		
}
